// 学生信息 
module.exports = app=>{
    const {STRING,INTEGER } = app.Sequelize;
    const Student = app.model.define('student',{
        name:{
            type:STRING,
            allowNull: false,
            comment:'学生姓名'
        },
        number:{
            type:INTEGER,
            allowNull: false,
            primaryKey: true, // 是否为主键
            unique: true, // 是否唯一
            autoIncrement: true, // 是否为自增
            comment:'学号'
        },
        sex:{
            type:STRING,
            allowNull: false,
            comment:'性别'
        },
        class_name:{
            type:STRING,
            allowNull: false,
            comment:'班级'
        },
        phone:{
            type:STRING,
            unique: true,
            allowNull: false,
            comment:'电话号'
        },
        address:{
            type:STRING,
            allowNull: false,
            comment:'住址'
        },
        idcard:{
            type:STRING,
            unique: true,
            allowNull: false,
            comment:'身份证号'
        },
        project_name:{
            type:STRING,
            allowNull: false,
            comment:'所属项目'
        },
        state:{
            type:STRING,
            allowNull: false,
            comment:'状态'
        },
        thousand:{
            type:STRING,
            allowNull: true,
            comment:'千分制'
        },
        award:{
            type:STRING,
            allowNull: true,
            comment:'获奖'
        },
        work:{
            type:STRING,
            allowNull: true,
            comment:'作品展示'
        },
        score_grouping:{
            type:STRING,
            allowNull: true,
            comment:'成绩分组'
        },
    })
    Student.associate = function () {
        app.model.Student.belongsTo(app.model.Project, {
            foreignkey: 'project_name',
            targetkey: 'name',
            as: 'project'
        })
        app.model.Student.belongsTo(app.model.Class, {
            foreignkey: 'class_name',
            targetkey: 'name',
            as: 'class'
        })
    }
    return Student
}